package other.edan.intlpass.utils;

import com.alibaba.fastjson.JSONObject;
import com.rkhd.platform.sdk.creekflow.approvalevent.ApprovalEventResponse;

//功能描述：返回消息工具类

public class TfReturnMsgTools {
	public static final int VM_SUCCESS = 0;  	 	//成功
	public static final int VM_FAIL = 1;   				//失败
	public static final int VM_EXCEPTION = 2;   	//异常

	/*功能描述：获取成功返回信息
	 * msg：返回信息
	 */
	public static String getSuccessResult(String msg) {
		JSONObject result = new JSONObject();
		result.put("code", VM_SUCCESS);
		result.put("msg", msg);
		return result.toJSONString();
	}

	public static String getSuccessResult(String msg,Long id) {
		JSONObject result = new JSONObject();
		result.put("code", VM_SUCCESS);
		result.put("msg", msg);
		result.put("id", id);
		return result.toJSONString();
	}
	
	/*功能描述：获取失败返回信息
	 * msg：返回信息
	 */
	public static String getFailResult(String msg) {
		JSONObject result = new JSONObject();
		result.put("code", VM_FAIL);
		result.put("msg", msg);
		return result.toJSONString();
	}
	
	/*功能描述：获取异常返回信息
	 * msg：返回信息
	 */
	public static String getExceptionResult(String msg) {
		JSONObject result = new JSONObject();
		result.put("code", VM_EXCEPTION);
		result.put("msg", msg);
		return result.toJSONString();
	}
	
	/*功能描述：获取异常返回信息
	 * msg：返回信息
	 */
	public static String getJsonResult(Boolean code,String msg) {
		JSONObject result = new JSONObject();
		result.put("code",  code ? VM_SUCCESS:VM_FAIL);
		result.put("msg", msg);
		return result.toJSONString();
	}
	
	/*功能描述：审批流返回结果
	 * 参数 b:成功或失败
	 * 参数：msg：返回消息
	 */
	public static ApprovalEventResponse getApprResponse(Boolean b, String msg) {
		ApprovalEventResponse response = new ApprovalEventResponse();
		response.setSuccess(b);
		response.setMsg(msg);
		return response;
	}
}
